<?php
/**
 *
 * @author fanzhanao
 * @version 
 */

class cartoon_model_bmodel extends Model{
	/**
	 *
	 * @var IDatabase
	 */	
	public function __construct(){
		parent::__construct();
	}
	
/**
	 * 修改数据
	 *
	 * @param unknown_type $args
	 * @param unknown_type $tbname
	 * @return unknown
	 */
	public function modifyData($args,$tbname = '',$key = 'id'){
		$_key = $key?$key:'id';
		if(!$args[$_key]) return false;
		$tbname = $tbname?$tbname:$this->table;
		$id = array_shift($args);
		if(!$args) return false;
		$setField = '';
		$split = '';
		$sql = 'UPDATE '.$tbname.' SET ';
		foreach($args as $k=>$v){
			if($v){
				if(is_numeric($v))
					$setField.=$split.$k."={$v}";
				else 
					$setField.=$split.$k."='{$v}'";
				$split=',';
			}
		}
		$sql.=$setField.' WHERE '.$_key.'='.$id;
		if($this->db->query($sql)){
			//更新缓存
			return true;
		}
		return false;
	}
}

?>